<?php

namespace app\mpopen\controller;

use app\common\controller\Frontend;
use app\common\model\Order;

class Index extends Frontend
{

    protected $layout = '';

    public function _initialize()
    {
        parent::_initialize();
    }

    public function index()
    {
        $mp_id = input('mp_id');
        $order_id = input('order_id');
        $orderData = Order::get(['order_id'=>$order_id]);
        if (!isset($orderData)) $this->error('查询不到正确的订单信息');
        $this->view->assign('orderData', $orderData);
        $this->view->assign('mp_id', $mp_id);
        $this->view->assign('order_id', $order_id);
        return $this->view->fetch();
    }

    public function news()
    {
        $newslist = [];
        return jsonp(['newslist' => $newslist, 'new' => count($newslist), 'url' => 'http://www.uctoo.com?ref=news']);
    }

    /**
     * 微信支付二维码收银台方法
     * 需要微信扫码支付功能的地方带上order表的id参数跳转到此地址即可。https://www.uctoo.com/mpopen/unipay/wxpayqc/mp_id/公众号表mp_id字段/order_id/
     * @return mixed
     */
    public function wxpayqc()
    {
        $mp_id = input('mp_id');
        $order_id = input('order_id');
        $orderData = Order::get(['order_id'=>$order_id]);
        if (!isset($orderData)) $this->error('查询不到正确的订单信息');
        $this->view->assign('orderData', $orderData);
        $this->view->assign('mp_id', $mp_id);
        $this->view->assign('order_id', $order_id);
        return $this->view->fetch();
    }
}
